import 'package:color_dart/color_dart.dart';
import 'package:flutter/material.dart';
import 'package:im_flutter_sdk_example/components/a_row/a_row.dart';
import 'package:im_flutter_sdk_example/pages/toolbar/mine/head.dart';
import 'package:im_flutter_sdk_example/utils/Icon.dart';
import 'package:im_flutter_sdk_example/utils/global.dart';

class Mine extends StatefulWidget {
  static _MineState _mineState;

  getAppBar() => _mineState.createAppBar();

  Mine() {
    _mineState = _MineState();
  }

  _MineState createState() => _MineState();
}

class _MineState extends State<Mine> with AutomaticKeepAliveClientMixin {
  AppBar createAppBar() {
    return null;
  }

  @override
  void initState() {
    super.initState();
    print("mine initState");
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
        body: SingleChildScrollView(
      child: Container(
        color: rgba(248, 248, 248, 1),
        child: Column(
          children: [
            Padding(
              padding: const EdgeInsets.only(bottom: 4),
              child: Column(
                children: <Widget>[
                  // 头部
                  Container(
                    alignment: Alignment.centerLeft,
                    height: 227,
                    decoration: BoxDecoration(
                      image: DecorationImage(
                        image: AssetImage(
                            "lib/assets/images/mine/mine-head-bg.png"),
                        fit: BoxFit.cover,
                      ),
                    ),
                    padding: EdgeInsets.only(left: 20, right: 20, top: 50),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        Container(
                            alignment: Alignment.centerRight,
                            child: icontupian18(
                                size: 24, color: rgba(255, 255, 255, .9))),
                        buildUser(),
                        HeadSectionOne(),
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              child: Column(
                children: [
                  HeadSectionThree(),
                  // HeadSectionFour(),
                ],
              ),
            ),
          ],
        ),
      ),
    ));
  }

  ARow buildUser() {
    // UserData userData = G.user.data;
    var userData = G.user.data;
    return ARow(
      height: 68,
      color: Colors.transparent,
      border: G.borderBottom(show: false),
      padding: EdgeInsets.all(0),
      leftChild: ClipRRect(
          borderRadius: new BorderRadius.circular(34),
          child: Image.asset(
            'lib/assets/images/default_avatar.png',
            width: 68,
            height: 68,
            fit: BoxFit.cover,
          )),
      centerChild: Container(
        margin: EdgeInsets.only(left: 10),
        child: Text(
          userData == null ? '请登录' : '${userData.realName}',
          style: TextStyle(color: rgba(255, 255, 255, 1), fontSize: 18),
        ),
      ),
      rightChild: icontupian6(size: 14, color: rgba(255, 255, 255, .6)),
      onPressed: () {
        return G.pushNamed('/quick_login');
      },
    );
  }

  @override
  bool get wantKeepAlive => true;
}
